/**
 * @Author: linzp
 * @Date: 2023/04/14/14:30
 */
public class demo0414 {
    public static void main(String[] args) {
        double total = 500000;
        double rate = 0.035;
        double cost = 50000;
        int year = 0;
        double have;
        while (Math.abs(total) > 0) {
            have = total + (total * rate) - cost;
            total = have;
            year++;
            System.out.println(year + "--" + total);
            if ((int)Math.abs(total) < cost) {
                return;
            }
        }
//        for (int i = 0; i < 90; i++) {
//            have = total + (total * rate) - cost;
//            total = have;
//            year++;
//            System.out.println(year+"--"+total);
//        }
//        double a = 8707.792802975811;
//        System.out.println(a*a);//7.582565549955733E7
    }
}
